#include "Scene.h"
#include "Point.h"
#include "Shop.h"
#include "Interface.h"
#include <ncurses.h> 
#include "MyFileTools.h"
#include "FileSave.h"

                        
// int main()
// {
    // Player p("abc");
    // Scene s(WIDTH, HEIGHT, p);
    // while (1)
    // {
    //     system("clear");
    //     s.show();
    //     p.show();
    //     p.Move();
    //     s.BuyInShop();
    //     Monster *m = s.IsInSamePlace();
    //     if (m)
    //     {
    //         Battle(p, *m);
    //     }
    // }
    // auto [username, password] = CreateLoginInterface();
    // auto [name,password1]=CreateRegisterface();
    // std::vector<std::string> user;
    // std::string n="test";
    // user.push_back(name);
    // FileTools::WriteLine(n.c_str(),user);
    // std::vector<std::string> user1=FileTools::ReadLine("test");
    // for (const auto& element : user1) {
    //     std::cout << element << " ";
    //}
//     return 0;
// }

void run()
{
    UserOperationsProxy proxy;
    homepage(proxy);
    Player p(proxy.currentUser->username);
    std::shared_ptr<Scene> s;
    std::shared_ptr<Scene> s1 = std::make_shared<Scene1>(WIDTH, HEIGHT, p);
    std::cout<<"创建场景1.....\n";
    sleep(1);
    std::shared_ptr<Scene> s2 = std::make_shared<Scene2>(WIDTH, HEIGHT, p);
    std::cout<<"创建场景2.....\n";
    sleep(1);
    std::shared_ptr<Scene> s3 = std::make_shared<Scene3>(WIDTH, HEIGHT, p);
    std::cout<<"创建场景3.....\n";
    sleep(1);
    s=s1;
    FileSave& fileSave = FileSave::getInstance();
    fileSave.p=&p;
    fileSave.s=s.get();
    while (1)
    {
        system("clear");
        s->show();
        p.show();
        p.Move(s,s1,s2,s3);
        s->FindTreasure(); //发现宝藏
        s->BuyInShop();
       
        Monster *m = s->IsInSamePlace();
        if (m)
        {
            Battle(p, *m);
        }
    }
}


int main() 
{

run();


}